1. Field of the Invention
The present invention particularly relates to an image processing apparatus, a method for processing an image, and a program that are desirably used in coordinate transforms performed on images.
2. Description of the Related Art
Currently, an image processing apparatus that performs geometric transformation, such as keystone correction or lens correction, on an image captured by a camera or the like is known. In such an image processing apparatus that performs geometric transformation, first, input pixels corresponding to one screen are stored in a memory. Next, by performing inverse transforms of coordinate transforms used in the geometric transformation, the coordinate values of the input pixels are calculated from the coordinate values of output pixels in order of scanning of the output pixels. Furthermore, a process is repeated in which pixels adjacent to the input pixels are read from the memory using integer parts of the coordinates of each input pixel obtained as a result of the inverse transform, interpolation is performed using fractional parts of the coordinates of the adjacent pixels and each input pixel, and the value of the corresponding output pixel is determined. This process is called a “coordinate transform during reading”, and image processing for the geometric transformation is realized through this process. For example, in Japanese Patent Laid-Open No. 2005-135096, a method for processing an image is disclosed in which an output image is divided into tiles and coordinate transforms during reading are performed for each tile.
If keystone correction for a front projector or lens correction for a camera is performed, an enlargement ratio when an input image is transformed into an output image is about 0.6 at minimum and about 1.25 at maximum. Furthermore, images need to be input and output in real-time in some cases. If the above-described method for processing an image is used while inputting and outputting images with 1 [pixel/cyc], the sum of the peak values of a necessary memory band during writing and reading undesirably becomes (1+1/minimum value of enlargement ratio) [pixels/cyc]. For example, if the minimum value of the enlargement ratio is 0.6, a memory band of 2.67 [pixels/cyc] is necessary at the peak. Thus, a large memory band is necessary in some cases, which is problematic.
On the other hand, a type of geometric transformation called a “coordinate transform during writing” is known. In this method, first, the coordinates of output pixels are calculated for input pixels, which are input in order of scanning, through coordinate transforms. Next, storage addresses in a memory are calculated from integer parts of the coordinates of the output pixels. Furthermore, inverse transforms of the coordinate transforms are performed on the integer parts of the coordinates of the output pixels to obtain coordinates in an input image. If integer parts of each set of coordinates obtained as a result of the inverse transform match those of the original set of coordinates of the corresponding input pixel, a pixel value to be output is obtained by performing interpolation using pixels adjacent to the input pixel and fractional parts of the coordinates obtained as a result of the inverse transform of the coordinate transform. The pixel value is stored in the storage address obtained before.
If the coordinate transform during writing is performed, the sum of the peak values of a memory band used during writing and reading is (1+maximum value of enlargement ratio) [pixels/cyc]. For example, even if the maximum value of the enlargement ratio is 1.25, the necessary memory band can be suppressed to 2.25 [pixels/cyc]. Thus, within the assumed enlargement ratio range, the peak value of the memory band can be smaller than in the coordinate transform during reading.
On the other hand, if the coordinate transform during writing is performed, pixels that are not output might be generated. Therefore, for example, in Japanese Patent Laid-Open No. 6-149993, a method in which generation of pixels that are not output is suppressed by scanning the coordinates of input pixels in units of sub-pixels is disclosed.
In the method disclosed in Japanese Patent Laid-Open No. 6-149993, a total of eight transform calculations, namely calculations of coordinate transforms for four sets of coordinates and calculations of inverse transforms for four sets of coordinates, are necessary even if sub-pixel scanning is performed after dividing a pixel in half in an x-axis direction and a y-axis direction. Especially in a projective transform, which is one of types of geometric transformation, the calculation amount is substantially the same between the coordinate transform and the inverse transform, and both the coordinate transform and the inverse transform include divisions. Accordingly, the amount of processing in each transform calculation is large. Therefore, in the method disclosed in Japanese Patent Laid-Open No. 6-149993, the size of circuits is large and the amount of processing in each calculation is large, which are problematic.